﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Xml;

namespace NewtifyMe.ParseFeeds
{
    public class SincronizationFeed
    {

        public  static List<RssFeedItem> GetFeed(String url)
        {
            XmlReader reader = XmlReader.Create("http://feeds.feedburner.com/PublicoDesporto?format=xml");
            SyndicationFeed feed = SyndicationFeed.Load(reader);


            List<RssFeedItem> retu = new List<RssFeedItem>();

            foreach (SyndicationItem item in feed.Items)
            {
                String title = item.Title.Text;


                String categorys = "";

                foreach (var category in item.Categories)
                {
                    categorys += categorys.ToString() + " ";
                }

                retu.Add(new RssFeedItem()
                             {
                                 Title = title,
                                 Categorys =  categorys,
                                 PublishDate = item.PublishDate.ToString()

                             });

            }

            return retu;
        } 
    }
}
